﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using CodeFirstDemo.Data;
using CodeFirstDemo.Model;

namespace CodeFirstDemo.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {

            using (var context = new CodeFirstDBContext())
            {
                User user = new User()
                {
                    Name = "Morteza",
                    BillingAddress = new Address() { City = "", Street = "", ZipCode = "" }
                };

                context.Users.Add(user);
                context.SaveChanges();
            }


            ViewBag.Message = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            return View();
        }
    }
}
